package com.mqz.seckill.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class MQConsumer {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @RabbitListener(queues = "queue")
    public void receive(Object msg) {
        log.info("接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_fanout01")
    public void receiveFromFanout01(Object msg) {
        log.info("queue_fanout01 接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_fanout02")
    public void receiveFromFanout02(Object msg) {
        log.info("queue_fanout02 接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_direct01")
    public void receiveFromDirect01(Object msg) {
        log.info("queue_direct01 接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_direct02")
    public void receiveFromDirect02(Object msg) {
        log.info("queue_direct02 接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_topic01")
    public void receiveFromTopic01(Object msg) {
        log.info("queue_topic01 接收消息：" + msg);
    }

    @RabbitListener(queues = "queue_topic02")
    public void receiveFromTopic02(Object msg) {
        log.info("queue_topic02 接收消息：" + msg);
    }
}
